<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>选择收货地址</title>
    <link rel="stylesheet" href="../css/reset.css">
    <link rel="stylesheet" href="../node_modules/mint-ui/lib/style.css">
    <link rel="stylesheet" href="../css/address.css">
</head>

<body>
    <div id="app">
        <mt-header fixed title="选择收货地址">
            <a href="./shop_cart.html" slot="left">
                <mt-button icon="back"></mt-button>
            </a>
        </mt-header>
        <div class="address_group">
            <div class="address1" v-for="item in addresses">
                <div class="address1_group">
                    <p>{{item.consignee}}</p>
                    <p>{{item.mobile}}</p>
                    <p>{{item.address_info}}</p>
                </div>
                <label class="radio_1">
                    <input type="radio" class="trulyRadio" :value="item.address_info" v-model="picked" @change="show_value">
                    <span class="falseRadio"></span>
                </label>
            </div>
        </div>
        <button class="add_address" @click="add">添加新地址</button>
    </div>
    <script src="../node_modules/jquery/dist/jquery.min.js"></script>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script src="../node_modules/mint-ui/lib/index.js"></script>
    <script src="../js/global.js"></script>
    <script>
        let vm = new Vue({
            el: "#app",
            data: {
                addresses:'',
                picked: ''
            },
            created(){
                var token = GetQueryString('token');
                $.ajax({
                    url:BaseUrl+'/index.php/Api/UserCenterApi/getAddressList',
                    dataType:'json',
                    type:'post',
                    data:{
                        'token':token
                    },
                    success(data){
                        console.log(data.data);
                        vm.addresses = data.data;
                        vm.addresses.forEach(item=>{
                            item.is_default = 0;
                        })
                    },
                    error(err){
                        console.log(err);
                    }
                })
            },
            methods: {
                show_value(e) {
                    console.log(e.target.value);
                },
                add(){
                    window.location.href="./add_address.html";
                }
            }
        })
    </script>
</body>

</html>